package com.ruoyi.common.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum BaseStatusEnum {

    ENABLE(1, "可用"),
    UNABLE(0, "不可用"),
    DELATED(-1, "已删除"),
    ;

    private Integer value;
    private String label;

    BaseStatusEnum(Integer value, String label){
        this.value = value;
        this.label = label;
    }

    public static String getLabelByValue(Integer value){
        for (BaseStatusEnum statusEnum: values()){
            if (statusEnum.getValue().equals(value)){
                return statusEnum.getLabel();
            }
        }
        return null;
    }

    public static List<Map<String, Object>> getMapList(){
        List<Map<String, Object>> resultList = new ArrayList<>();
        for (BaseStatusEnum item : values()) {
            Map<String, Object> itemMap = new HashMap<>();
            itemMap.put("name", item.getLabel());
            itemMap.put("value", item.getValue());
            resultList.add(itemMap);
        }
        return resultList;
    }

}
